import { createPinia } from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";

// 创建 Pinia 实例
const pinia = createPinia();

// 添加持久化插件
pinia.use(
  createPersistedState({
    // 默认使用 localStorage
    storage: localStorage,
    // 序列化配置
    serializer: {
      serialize: JSON.stringify,
      deserialize: JSON.parse,
    },
    // 全局配置
    key: (id) => `cardcaptor-sakura-${id}`,
    // 调试模式
    debug: import.meta.env.DEV,
  }),
);

export default pinia;

// 导出所有 store
export { useUserStore } from "./user";
export { useChatStore } from "./chat";
export { usePersonaStore } from "./persona";
export { useAppStore } from "./app";
export { useThemeStore } from "./theme";
